package com.zhangkeyou.map.mapweb.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangkeyou.map.mapweb.domain.entity.MyFile;
import com.zhangkeyou.map.mapweb.util.MyUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface FileMapper extends BaseMapper<MyFile> {
    @Select("select * from filelist where userinfo_id = #{userid}")
    public List<MyFile> selectByUserid(String userid);

    @Select("select file_path from filelist where id = #{id} and userinfo_id = #{userinfoId} and source = #{source}")
    String getFilePath(MyFile myFile);

    @Update("update filelist set article_id = #{articleId} where id = #{fileId} ")
    int updateArticleId(@Param("fileId") String fileId,@Param("articleId") String articleId);

    @Select("select * from filelist where source = #{source} and article_id is null")
    List<MyFile> getImageInNullArticle(@Param("source")MyUtils.FileSource source);

    List<String> getFileIdListByArticleId(@Param("articleId") String articleId,@Param("source") MyUtils.FileSource source);

    List<MyFile> selectFileListWithoutPath(@Param("userId") String userId,@Param("source") MyUtils.FileSource source);
}
